﻿<%@page import="itsm.isperp.module.entity.app.AppDepartment"%>
<%@page import="itsm.isperp.module.service.app.AppDepartmentService"%>
<%@page import="itsm.isperp.framework.utils.DateUtils"%>
<%@page
	import="org.springframework.security.core.session.SessionInformation"%>
<%@page
	import="org.springframework.security.authentication.AuthenticationManager"%>
<%@page import="itsm.isperp.module.entity.app.AppUser"%>
<%@page import="java.util.List"%>
<%@page import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@page
	import="org.springframework.security.core.session.SessionRegistryImpl"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%
	SessionRegistryImpl sessionRegistry = ContextHolder
			.getSpringBean("sessionRegistry");
	List<Object> list = sessionRegistry.getAllPrincipals();
%>
<h2>
	后台登陆在线用户:<%=list.size()%></h2>
<table class="form-table" style="padding:3px">
	<tr>
		<td style="width:120px">帐号</td>
		<td style="width:120px">姓名</td>
		<td style="width:180px">部门</td>
		<td>会话信息<ui /td>
	</tr>
	<%
		AppDepartmentService appDepartmentService = ContextHolder
				.getSpringBean("appDepartmentService");
		for (Object o : list) {
			List<SessionInformation> ss = sessionRegistry.getAllSessions(o,
					false);

			AppUser u = (AppUser) o;
	%>
	<tr>
		<td><%=u.getName()%></td>
		<td><%=u.getFullname()%></td>
		<td>
			<%
				AppDepartment d = appDepartmentService.findOne(u
							.getAppDepartmentId());
					if (d != null) {
						out.write(d.getName());
					}
			%>
		</td>
		<td>
			<%
				for (SessionInformation se : ss) {
						out.write(se.getSessionId() + "（" + !se.isExpired() + "）："
								+ DateUtils.formatDateTime(se.getLastRequest())
								+ "<br>");
					}
			%>
		</td>
	</tr>
	<%
		}
	%>

</table>

<%
	AuthenticationManager authenticationManager = ContextHolder
			.getSpringBean("isperp.authenticationManager");

	int j = list.size();
%>












